<!--
 * @Author: your name
 * @Date: 2021-09-24 10:25:45
 * @LastEditTime: 2021-09-24 11:35:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \bigdatavue\src\views\others\components\tooltip.vue
-->
<template>
    <div class="menus">
        <div class="menus_header">
            <span><svg-icon icon-class="nested" size="1.1"></svg-icon></span>
            <span>节点操作</span>
        </div>
        <div class="menus_content">
            <div
                v-for="(item, index) in bars"
                :key="index"
                class="menus_content_cell"
                @click="handleClick(item)"
            >
                <div>
                    <span><svg-icon :icon-class="item.icon" size="1.1"></svg-icon></span>
                    <span>{{ item.name }}</span>
                </div>
                <div>
                    {{ item.cmd }}
                </div>
            </div>
        </div>
    </div>
</template>

<script lang="ts">
import { defineComponent, toRaw, ref } from 'vue'

interface BarTypes {
  name: String;
  cmd: String;
  id: String;
  icon: String;
}
export default defineComponent({
    name: 'Tooltip',
    emits: {
        handleClick: null,
    },
    setup(_, { emit }) {
        let bars = ref<BarTypes[]>()
        bars.value = [
            {
                name: '移除',
                cmd: 'Ctrl+D',
                id: 'remove',
                icon: 'bug',
            },
            {
                name: '执行',
                cmd: 'Ctrl+S',
                id: 'todo',
                icon: 'checkbox',
            },
            {
                name: '编辑',
                cmd: 'Ctrl+E',
                id: 'edit',
                icon: 'exit-fullscreen',
            },
        ]
        // 事件
        const handleClick = (item: BarTypes) => {
            let { name, id } = item
            emit('handleClick', { name, id })
        }
        return {
            bars,
            handleClick,
        }
    },
})
</script>

<style lang="less">
.menus {
  width: 100%;
  display: flex;
  flex-direction: column;
  background: #fff;

  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  overflow: hidden;
  &_header {
    background: #007fff;
    color: #fff;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 5px;
    & > span:nth-of-type(1) {
      display: flex;
      align-items: center;
      margin-right: 10px;
    }
  }
  &_content {
    &_cell {
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: #666;
      font-size: 13px;
      padding: 5px 5px;
      border-bottom: 1px solid #eee;
      background: #fff;
      &:hover {
        background: rgb(240, 236, 236);
      }
      & > div:nth-of-type(1) {
        display: flex;
        align-items: center;
        & > span:nth-of-type(1) {
          display: flex;
          align-items: center;
          margin-right: 5px;
        }
        & + div {
          font-size: 12px;
        }
      }
    }
  }
}
</style>
